package com.gaogzhen.algorithm.leetCode;

/**
 * 剑指 Offer 58 - II. 左旋转字符串
 */
public class LeftRotationString {
    public static void main(String[] args) {
        String s = "absfsskme";
        int len = 3;
        System.out.println(reverseLeftWords2(s, len));
    }
    public static String reverseLeftWords1(String s, int n) {
        StringBuilder sb = new StringBuilder();
        char[] chars = s.toCharArray();
        int len = chars.length;
        for (int i = n; i < len; i++) {
            sb.append(chars[i]);
        }
        for (int i = 0; i < n; i++) {
            sb.append(chars[i]);
        }
        return sb.toString();
    }
    public static String reverseLeftWords2(String s, int n) {
        return s.substring(n, s.length()) + s.substring(0, n);
    }

}
